import { createApp } from 'vue'
import App from './App.vue'
import router from './router';
// import { CapacitorUpdater } from '@capgo/capacitor-updater';
// import { SplashScreen } from '@capacitor/splash-screen'


import { IonicVue } from '@ionic/vue';

/* Core CSS required for Ionic components to work properly */
import '@ionic/vue/css/core.css';

/* Basic CSS for apps built with Ionic */
import '@ionic/vue/css/normalize.css';
import '@ionic/vue/css/structure.css';
import '@ionic/vue/css/typography.css';

/* Optional CSS utils that can be commented out */
import '@ionic/vue/css/padding.css';
import '@ionic/vue/css/float-elements.css';
import '@ionic/vue/css/text-alignment.css';
import '@ionic/vue/css/text-transformation.css';
import '@ionic/vue/css/flex-utils.css';
import '@ionic/vue/css/display.css';

/* Theme variables */
import './theme/variables.css';

const app = createApp(App)
  .use(IonicVue)
  .use(router);
  
router.isReady().then(() => {
  app.mount('#app');
});

// let data = {version: ""}
// CapacitorUpdater.notifyAppReady();
// App.addListener('appStateChange', async(state) => {
//   if (state.isActive) {
//     // Do the download during user active app time to prevent failed download
//     data = await CapacitorUpdater.download({
//       version: '0.0.4',
//       url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
//     })
//   }
//   if (!state.isActive && data.version !== "") {
//     // Do the switch when user leave app
//     SplashScreen.show()
//     try {
//       await CapacitorUpdater.set(data)
//     } catch (err) {
//       console.log(err)
//       SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
//     }
//   }
// })

